package com.lzw.mapper.admin;

import com.lzw.pojo.Announcement;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface AnnouncementMapper {

    //查询公告
    List<Announcement> listAnnouncement(@Param("dataPosted") LocalDate dataPosted, @Param("postedBy") String postedBy);

    //添加公告
    @Insert("INSERT INTO dormitorymanagement.announcement(title, content, date_posted, posted_by) VALUES (#{title}, #{content}, #{datePosted}, #{postedBy})")
    void addAnnouncement(Announcement announcement);

    //批量删除公告
    void deleteAnnouncement(@Param("ids") List<Integer> ids);

    //根据id查询公告
    @Select("SELECT * FROM dormitorymanagement.announcement WHERE announcement_id = #{announcementId}")
    Announcement getAnnouncementById(int id);

    //更新公告
    void updateAnnouncement(Announcement announcement);
}
